package com.taobao.report.util;

import org.apache.commons.lang3.StringUtils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class DateUtil {
    private static DateUtil dateUtil;
    /**时间格式 yyyy_MM_dd_HH_mm_ss*/
    public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
    /**时间格式 yyyy_MM_dd*/
    public static final String yyyy_MM_dd = "yyyy-MM-dd";
    /**时间格式 yyyy_MM_dd*/
    public static final String yyyyMM = "yyyyMM";

    /**时间格式 yyyyMMddHHmmss*/
    public static final String yyyyMMddHHmmss = "yyyyMMddHHmmss";
    public static final String yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";
    private DateUtil(){
    }
    /**
     * 获取DateUtil实例
     */
    public static DateUtil getInstance(){
        //if(dateUtil==null){
        synchronized(DateUtil.class){
            if(dateUtil==null){
                dateUtil=new DateUtil();
            }
        }
        //}
        return dateUtil;
    }
    /**
     * 根据传入的日期格式化输出
     * yyyy-MM-dd 的字符串时间
     *
     * @param date      时间
     * @param formatStr yyyy-MM-dd等时间串
     *
     * @return
     */
    public String formatDate(Date date,String formatStr){
        if (StringUtils.isEmpty(formatStr)) {
            formatStr = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat formatter = new SimpleDateFormat(formatStr);
        String outDate = formatter.format(date);
        return outDate;
    }
    /**
     * 将传入的字符串转化为对应的日期格式
     *
     * @param s          时间字符串
     * @param formateStr 格式化的时间格式
     *
     * @return
     */
    public Date parseDate(String s,String formateStr){
        SimpleDateFormat formatter=new SimpleDateFormat(formateStr);
        Date date;
        try{
            date=formatter.parse(s);
            return date;
        }catch(ParseException e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 将传入的字符串转化为对应的日期格式
     *
     * @param s          时间字符串
     * @param formateStr 格式化的时间格式
     *
     * @return
     */
    public Date parseDateException(String s,String formateStr) throws Exception{
        SimpleDateFormat formatter=new SimpleDateFormat(formateStr);
        formatter.setLenient(false);
        Date date=formatter.parse(s);
        return date;
    }
    /**
     * 比较两个时间的大小
     *
     * @param dateTime1 时间1
     * @param dateTime2 时间2
     *
     * @return 0 表示相等,返回 1 表示日期1>日期2,返回 -1 表示日期1<日期2
     */
    public int compareDate(Date dateTime1,Date dateTime2){
        return dateTime1.compareTo(dateTime2);
    }
    /**
     * 比较两个时间的大小
     *
     * @param dateTime1 时间1
     * @param dateTime2 时间2
     * @param formatStr 格式化时间
     *
     * @return 0 表示相等,返回 1 表示日期1>日期2,返回 -1 表示日期1<日期2
     */
    public int compareDate(Date dateTime1,Date dateTime2,String formatStr){
        String t1=formatDate(dateTime1,formatStr);
        String t2=formatDate(dateTime2,formatStr);
        return compareDate(parseDate(t1, formatStr), parseDate(t2, formatStr));
    }
    /**
     * 比较多个时间的大小,获取比时间大的或者时间小的集合
     *
     * @param date      被比较时间
     * @param dateList  比较的时间集合
     * @param formatStr 格式化时间
     * @param flag      true表示获取大的,false表示获取小的
     *
     * @return 时间结果集
     */
    public List<Date> maxOrMinDate(Date date,List<Date> dateList,String formatStr,boolean flag){
        List<Date> resultDate = new ArrayList<Date>();;
        String t1=formatDate(date,formatStr);
        if(flag){//获取大的
            for(Date d : dateList){
                String t2=formatDate(d,formatStr);
                if(compareDate(parseDate(t1,formatStr),parseDate(t2,formatStr))==-1){
                    resultDate.add(d);
                }
            }
        }else{//获取小的
            for(Date d : dateList){
                String t2=formatDate(d,formatStr);
                if(compareDate(parseDate(t1,formatStr),parseDate(t2,formatStr))==1){
                    resultDate.add(d);
                }
            }
        }
        return resultDate;
    }
    /**
     * 时间减法
     *
     * @param strDate 时间字符串格式
     * @param day     要减去的天数
     * @param format  时间格式
     *
     * @return
     */
    public Long minusDate(String strDate,int day,String format){
        Date sDate=parseDate(strDate, format);
        Calendar date=Calendar.getInstance();
        date.setTime(sDate);
        date.set(Calendar.DATE,date.get(Calendar.DATE)-day);
        return date.getTimeInMillis();
    }
    public Long minusDate(int day){
        Date sDate=new Date();
        Calendar date=Calendar.getInstance();
        date.setTime(sDate);
        date.set(Calendar.DATE,date.get(Calendar.DATE)-day);
        return date.getTimeInMillis();
    }

    /**
     * 减去天数
     * @param d
     * @param day
     * @return
     */
    public Date minusDateDay(Date d,int day){
        Calendar date=Calendar.getInstance();
        date.setTime(d);
        date.set(Calendar.DATE,date.get(Calendar.DATE)-day);
        return date.getTime();
    }
    /*
    * 减去月份
    * **/
    public Date minusDateMonth(int month) {
        Date sDate = new Date();
        Calendar date=Calendar.getInstance();
        date.setTime(sDate);
        date.set(Calendar.MONTH, date.get(Calendar.MONTH) - month);
        return date.getTime();
    }
    /*
    * 减去分钟
    * **/
    public Date minusDateMinute(int minute) {
        Date sDate = new Date();
        Calendar date=Calendar.getInstance();
        date.setTime(sDate);
        date.set(Calendar.MINUTE, date.get(Calendar.MINUTE) - minute);
        return date.getTime();
    }

    public Date minusDateSecond(int minute) {
        Date sDate = new Date();
        Calendar date=Calendar.getInstance();
        date.setTime(sDate);
        date.set(Calendar.SECOND, date.get(Calendar.SECOND) - minute);
        return date.getTime();
    }
    /**
     * 时间转换为Long类型
     *
     * @param strDate 时间字符串格式
     * @param format  时间格式
     *
     * @return
     */
    public Long parseDateStr(String strDate,String format){
        Date sDate=parseDate(strDate,format);
        //        SimpleDateFormat dft = new SimpleDateFormat(format);
        Calendar date=Calendar.getInstance();
        date.setTime(sDate);
        return date.getTimeInMillis();
    }

    /**
     * 把字符串转化为java.util.Date
     *
     * @param date
     * @param dateFormat
     */
    public Date getDateDate(Date date, String dateFormat) {
        Date rs = date;
        if ((date != null)) {
            SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
            String dateStr = sdf.format(date);
            try {
                rs = sdf.parse(dateStr);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return rs;
    }

    /**
     * 把字符串转化为java.util.Date
     *
     * @param date
     * @param dateFormat
     */
    public String getDateStr(Date date, String dateFormat) {
        String dateStr = "";
        if ((date != null)) {
            SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
            dateStr = sdf.format(date);
        }
        return dateStr;
    }

    /**
     * 当前日期的结束时间
     *
     * @param strDate
     * @param format
     *
     * @return
     */
    public Long lastMMofDay(String strDate,String format){
        Date sDate=parseDate(strDate,format);
        //        SimpleDateFormat dft = new SimpleDateFormat(format);
        Calendar date=Calendar.getInstance();
        date.setTime(sDate);
        date.add(Calendar.DAY_OF_MONTH, 1);
        return date.getTimeInMillis()-1;
    }
    /**
     * 格式化输出
     *
     * @param lDate
     *
     * @return
     */
    public String parseDate(Long lDate){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date dt=new Date(lDate);
        String sDateTime=sdf.format(dt);
        return sDateTime;
    }
    public String parseDateYMD(Long lDate){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date dt=new Date(lDate);
        String sDateTime=sdf.format(dt);
        return sDateTime;
    }
    public String parseDate(Long lDate,String fmt) throws Exception{
        SimpleDateFormat sdf=new SimpleDateFormat(fmt);
        Date dt=new Date(lDate);
        String sDateTime=sdf.format(dt);
        return sDateTime;
    }
    /**
     * 计算时间差
     *
     * @param begin
     * @param end
     *
     * @return
     */
    public String dateDifference(String begin,String end) throws ParseException{
        DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d1=new Date();
        if(StringUtils.isNotEmpty(end)){
            d1=df.parse(end);
        }
        Date d2=df.parse(begin);
        long diff=d1.getTime()-d2.getTime();//这样得到的差值是微秒级别
        long days=diff/(1000*60*60*24);
        long hours=(diff-days*(1000*60*60*24))/(1000*60*60);
        long minutes=(diff-days*(1000*60*60*24)-hours*(1000*60*60))/(1000*60);
        StringBuilder stringBuilder=new StringBuilder();
        if(days!=0L){
            stringBuilder.append(days).append("天");
        }
        if(hours!=0L){
            stringBuilder.append(hours).append("小时");
        }
        stringBuilder.append(minutes).append("分");
        return stringBuilder.toString();
    }
    /**
     * 当月最后一天
     *
     * @return
     */
    public String getLastDay(String month){
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar=Calendar.getInstance();
        calendar.setTime(parseDate(month+"-01","yyyy-MM-dd"));
        //上个月最后一天
        calendar.add(Calendar.MONTH,1);    //加一个月
        calendar.set(Calendar.DATE,1);        //设置为该月第一天
        calendar.add(Calendar.DATE,-1);    //再减一天即为上个月最后一天
        String day_last=df.format(calendar.getTime());
        StringBuffer endStr=new StringBuffer().append(day_last).append(" 23:59:59");
        day_last=endStr.toString();
        return day_last;
    }
    public long getLastDayOfCurrentMonth(){
        Calendar calendar=Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        //上个月最后一天
        calendar.add(Calendar.MONTH,1);    //加一个月
        calendar.set(Calendar.DATE,1);        //设置为该月第一天
        calendar.add(Calendar.MILLISECOND, -1);    //再减一秒即为上个月最后一天
        return calendar.getTimeInMillis();
    }
    public long getFirstDayOfCurrentMonth(){
        Calendar calendar=Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.DATE, 1);        //设置为该月第一天
        return calendar.getTimeInMillis();
    }
    /**
     * 获取两个月份之间月差
     *
     * @param begin
     * @param end
     *
     * @return
     */
    public int calculateMonthIn(String begin,String end){
        String beginDay=begin+"-01";
        String last=getLastDay(end);
        Date date1=parseDate(beginDay,"yyyy-MM-dd");
        Date date2=parseDate(last,"yyyy-MM-dd");
        Calendar cal1=new GregorianCalendar();
        cal1.setTime(date1);
        Calendar cal2=new GregorianCalendar();
        cal2.setTime(date2);
        int c=(cal1.get(Calendar.YEAR)-cal2.get(Calendar.YEAR))*12+cal1.get(Calendar.MONTH)-cal2.get(Calendar.MONTH);
        return Math.abs(c);
    }

    /**
     * 获取累加年份
     * @param date
     * @param years
     * @return
     */
    public int getAddYear(Date date, int years) {
        Calendar now = Calendar.getInstance();
        now.setTime(date);
        now.add(Calendar.YEAR, years);
        return now.get(Calendar.YEAR);
    }

    /**
     * 获取累加年份日期
     * @param date
     * @param years
     * @return
     */
    public Date getAddYearDate(Date date, int years) {
        Calendar now = Calendar.getInstance();
        now.setTime(date);
        now.add(Calendar.YEAR, years);
        Date d = now.getTime();
        return d;
    }

    /**
     * 获取累加小时日期
     * @param date
     * @param hours
     * @return
     */
    public Date getAddHourDate(Date date, int hours) {
        Calendar now = Calendar.getInstance();
        now.setTime(date);
        now.add(Calendar.HOUR, hours);
        Date d = now.getTime();
        return d;
    }

    /**
     * 获取累加小时日期
     * @param date
     * @param month
     * @return
     */
    public Date getAddMonthDate(Date date, int month) {
        Calendar now = Calendar.getInstance();
        now.setTime(date);
        now.add(Calendar.MONTH, month);
        Date d = now.getTime();
        return d;
    }
    /**
     * 功能描述：返回年
     *
     * @param date
     *            Date 日期
     * @return 返回年
     */
    public int getYear(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.YEAR);
    }
    /**
     * 功能描述：返回月
     *
     * @param date
     *            Date 日期
     * @return 返回月份
     */
    public int getMonth(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.MONTH) + 1;
    }

    /**
     * 功能描述：返回日
     *
     * @param date
     *            Date 日期
     * @return 返回日份
     */
    public int getDay(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.DAY_OF_MONTH);
    }

    /**
     * 功能描述：返回小
     *
     * @param date
     *            日期
     * @return 返回小时
     */
    public int getHour(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.HOUR_OF_DAY);
    }

    /**
     * 功能描述：返回分
     *
     * @param date
     *            日期
     * @return 返回分钟
     */
    public int getMinute(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.MINUTE);
    }

    /**
     * 返回秒钟
     *
     * @param date
     *            Date 日期
     * @return 返回秒钟
     */
    public int getSecond(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.SECOND);
    }

    /**
     * 功能描述：返回毫
     *
     * @param date
     *            日期
     * @return 返回毫
     */
    public long getMillis(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.getTimeInMillis();
    }

	/**
	 * 得到当前日期/时间字符串
	 * 
	 * @return 返回日期/时间字符串
	 */
	public static String getNowDateTimeString(String type) {
		Date date = new Date();
		SimpleDateFormat formattxt = new SimpleDateFormat(type);
		return formattxt.format(date);
	}
	
	public static String getTimeStringByDate(Date d, String type) {
        SimpleDateFormat formattxt = new SimpleDateFormat(type);
        return formattxt.format(d);
    }
	
	public static String getNowDateTimeString(Date date,String type) {
		SimpleDateFormat formattxt = new SimpleDateFormat(type);
		return formattxt.format(date);
	}
	
	
	public static Date addDate(Date date, int index) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.DATE, index);
		return cal.getTime();
	}

    /**
     * 得到当前月份的第一天
     * 当前月份加1，得到下一个月，然后天数减一，得到当前月份的最后一天日期
     * @return
     */
    public static String getCurrentMonthFirstDay() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar=Calendar.getInstance();
        calendar.add(Calendar.MONTH, 0);
        calendar.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天 
        String firstDay = format.format(calendar.getTime());
        return firstDay;
    }
    
    /**
     * 得到当前月份的最后一天
     * 当前月份加1，得到下一个月，然后天数减一，得到当前月份的最后一天日期
     * @return
     */
    public static String getCurrentMonthLastDay() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, 1);
        calendar.set(Calendar.DAY_OF_MONTH,0);
        String lastDay = format.format(calendar.getTime());
        return lastDay;
    }
    
    /**
     * 上个月份的第一天
     * @return
     */
    public static String getLastMonthFirstDay() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, -1);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        return format.format(calendar.getTime());
    }
    
    /**
     * 上个月份的最后一天
     * @return
     */
    public static String getLastMonthLastDay() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, 0);
        calendar.set(Calendar.DAY_OF_MONTH, 0); 
        return format.format(calendar.getTime());
    }
    
    public static String getDay(int month, int dayOfMonth) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, month);
        calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); 
        return format.format(calendar.getTime());
    }
    
    /**
     * 获取当月第一天
     * @return
     */
    public static String getFirstDateOfMonth() {
        // 获取当月第一天
        SimpleDateFormat format = new SimpleDateFormat(DateUtil.yyyy_MM_dd);
        // 获取前月的第一天  
        Calendar cale = Calendar.getInstance();
        cale.add(Calendar.MONTH, 0);
        cale.set(Calendar.DAY_OF_MONTH, 1);
        String firstday = format.format(cale.getTime()) + " 00:00:00";
        return firstday;
    }
    
    /**
     * 获取当月第一天
     * @return
     */
    public static String getFirstDateOfMonth(String pattern) {
        // 获取当月第一天
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        // 获取前月的第一天  
        Calendar cale = Calendar.getInstance();
        cale.add(Calendar.MONTH, 0);
        cale.set(Calendar.DAY_OF_MONTH, 1);
        String firstday = format.format(cale.getTime());
        return firstday;
    }
    
    /**
     * 获取前月的最后一天 
     * @return
     */
    public static String getLastDateOfMonth() {
        SimpleDateFormat format = new SimpleDateFormat(DateUtil.yyyy_MM_dd);
        // 获取前月的最后一天  
        Calendar cale = Calendar.getInstance();
        cale.add(Calendar.MONTH, 1);
        cale.set(Calendar.DAY_OF_MONTH, 0);
        String lastday = format.format(cale.getTime()) + " 23:59:59";
        return lastday;
    }

    /**
     * 将Date类转换为XMLGregorianCalendar
     * 
     * @param date
     * @return
     */
    public static XMLGregorianCalendar dateToXmlDate(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        DatatypeFactory dtf = null;
        XMLGregorianCalendar dateType = null;
        try {
            dtf = DatatypeFactory.newInstance();
            dateType = dtf.newXMLGregorianCalendar();
            dateType.setYear(cal.get(Calendar.YEAR));
            // 由于Calendar.MONTH取值范围为0~11,需要加1
            dateType.setMonth(cal.get(Calendar.MONTH) + 1);
            dateType.setDay(cal.get(Calendar.DAY_OF_MONTH));
            dateType.setHour(cal.get(Calendar.HOUR_OF_DAY));
            dateType.setMinute(cal.get(Calendar.MINUTE));
            dateType.setSecond(cal.get(Calendar.SECOND));
        } catch (DatatypeConfigurationException e) {
        }
        return dateType;
    }
    
    public static String getYesterday() {
        try {
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE,-1);
            Date time=cal.getTime();
            String yesterday = new SimpleDateFormat("yyyy-MM-dd").format(time);
            return yesterday;
        } catch (Exception e) {
            
        }
        return null;
    }

    /**
     * 获取两个日期之间的日期
     * @param start 开始日期
     * @param end 结束日期
     * @return 日期集合
     */
    public static List<String> getBetweenDatesOfDay(String startStr, String endStr) {
        List<String> result = new ArrayList<String>();
        try {
            Date start = DateUtil.getInstance().parseDate(startStr, "yyyy-MM-dd");
            Date end = DateUtil.getInstance().parseDate(endStr, "yyyy-MM-dd");
            Calendar tempStart = Calendar.getInstance();
            tempStart.setTime(start);
            
            Calendar tempEnd = Calendar.getInstance();
            tempEnd.setTime(end);
            tempEnd.add(Calendar.DAY_OF_YEAR, 1);
            while (tempStart.before(tempEnd)) {
                result.add(DateUtil.getInstance().formatDate(tempStart.getTime(), "yyyy-MM-dd"));
                tempStart.add(Calendar.DAY_OF_YEAR, 1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 获取两个日期之间的月份
     * @param start 开始日期
     * @param end 结束日期
     * @return 日期集合
     */
    public static List<String> getBetweenDatesOfMonth(String startStr, String endStr) {
        List<String> result = new ArrayList<String>();
        try {
            Date start = DateUtil.getInstance().parseDate(startStr, "yyyy-MM-dd");
            Date end = DateUtil.getInstance().parseDate(endStr, "yyyy-MM-dd");
            Calendar tempStart = Calendar.getInstance();
            tempStart.setTime(start);
            
            Calendar tempEnd = Calendar.getInstance();
            tempEnd.setTime(end);
            while (tempStart.before(tempEnd)) {
                result.add(DateUtil.getInstance().formatDate(tempStart.getTime(), "yyyy-MM"));
                tempStart.add(Calendar.MONTH, 1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static void main(String[] args){
        /*System.out.println(DateUtil.getInstance().parseDateStr("2015-04-01 00:00:00","yyyy-MM-dd HH:mm:ss"));
        System.out.println(DateUtil.getInstance().getFirstDayOfCurrentMonth());
        System.out.println(DateUtil.getInstance().getLastDayOfCurrentMonth());
        System.out.println(DateUtil.getInstance().parseDate(1429766777323L));*/
//        System.out.println(0/100);
//        System.out.println(getFirstDateOfMonth());
//        System.out.println(getLastDateOfMonth());
//        System.out.println(getFirstDateOfMonth("yyyy-MM-dd HH:mm:ss"));
//        System.out.println(getFirstDateOfMonth("yyyy-MM-dd"));
//        Date date = DateUtil.getInstance().parseDate("2015-10","yyyy-MM");
//        System.out.println(date);
//        //Long s = DateUtil.getInstance().lastMMofDay("2015-10-04", "yyyy-MM-dd");
        System.out.println(DateUtil.getInstance().getLastDay("2017-04"));
        Date date = DateUtil.getInstance().parseDate("201704","yyyyMM");
        String dateStr = DateUtil.getInstance().formatDate(date, "yyyy-MM-dd HH:mm:ss");
        System.out.println(dateStr);
//        System.out.println(DateUtil.getYesterday());
        
        try {
//            List<String> dataList = DateUtil.getBetweenDatesOfDay("2017-01-8", "2017-03-10");
//            for (int i = 0; i < dataList.size(); i++) {
//                String d = dataList.get(i);
//                System.out.println(d);
//            }
//            System.out.println("------------------------------------");
//            List<String> dataList1 = DateUtil.getBetweenDatesOfMonth("2017-01-08", "2017-03-10");
//            for (int i = 0; i < dataList1.size(); i++) {
//                String d = dataList1.get(i);
//                System.out.println(d);
//            }
            
            System.out.println(DateUtil.getFirstDateOfMonth()+"----"+DateUtil.getLastDateOfMonth());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
